package com.igame.mapper;

import com.igame.entity.Comment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Select("SELECT * FROM comment where goods_id=#{goodsId}")
    List<Comment> getAllParentComments(@Param("goodsId") Integer goodsId);

    @Insert("insert into comment(id, user, content, parentId, goods_id, is_new, reply_user) values (null,#{user},#{content},#{parentId},#{goodsId},#{isNew},#{replyUser})")
    int insertComment(Comment comment);

    @Select("SELECT * FROM comment where reply_user=#{userName} and user!=#{userName}")
    List<Comment> getReply(@Param("userName") String userName);
}
